//===============================================================================
// Q4Tech Engineering Team
// Mobile Updater Application Block - November 2006
//===============================================================================
// Copyright  Q4Tech Informatica Argentina.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Q4Tech.Engineering.UpdaterAgent.Common;

namespace Q4Tech.Engineering.Updater.SampleApp
{
    public partial class MainForm : Form
    {
        NotifierClient notifierClient;

        public MainForm()
        {
            notifierClient = new NotifierClient("{ED83BE04-9ACE-4a72-A1B1-2C06EF92E699}");

            notifierClient.Initialize();

            notifierClient.UpdatesAvailable += new NotifierClient.UpdatesAvailableHandler(notifierClient_UpdatesAvailable);
            notifierClient.UpdatingInProcess += new NotifierClient.UpdatingInProcessHandler(notifierClient_UpdatingInProcess);

            InitializeComponent();
        }

        bool notifierClient_UpdatingInProcess()
        {
            return MessageBox.Show("An update is available for this application. Do you want to quit now and install?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button2) == DialogResult.Yes;
        }

        bool notifierClient_UpdatesAvailable()
        {
            return MessageBox.Show("An update is available for this application. Do you want to download it?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button2) == DialogResult.Yes;
        }

        private void fontSizeTrackbar_ValueChanged(object sender, EventArgs e)
        {
            Font oldFont = this.sampleLabel.Font;
            Font newFont = new Font(oldFont.Name, this.fontSizeTrackbar.Value, oldFont.Style);
            this.sampleLabel.Font = newFont;
            oldFont.Dispose();
        }

        private void mainForm_Load(object sender, EventArgs e)
        {

#if version2
            this.sampleLabel.Text = Properties.Resources.SampleApp2;
            this.Text = Properties.Resources.SampleApp2;
#endif

#if version1
            this.sampleLabel.Text = Properties.Resources.SampleApp;
            this.Text = Properties.Resources.SampleApp;
#endif

        }
    }
}